Method and Apparatus for Automatically Optimizing the Loading of Images in a Cloud-Based Proxy Service

ABSTRACT

A web page is received at a client device. The web page includes at least one reference to an image. The client device determines a display size of the image. The client device transmits a request for the image, where the request includes an indication of a set of one or more requested dimensions for the image that is equal or substantially equal to the determined display size. The client device receives the image having a size that is equal or substantially equal to the set of requested dimensions, and the client device displays the image.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application claims the benefit of U.S. Provisional Application No.61/715,236, filed Oct. 17, 2012, which is hereby incorporated byreference.

FIELD

Embodiments of the invention relate to the field of networkcommunication; and more specifically, to automatically optimizing theloading of images in a cloud-based proxy service.

BACKGROUND

Images can be more than half of the data that makes up a typicalwebsite. Although there are tools that may automatically reduce the sizeof the images on behalf of the website owner, many of the images may notbe needed for the page as they may never be seen by the user. Forexample, some pages are longer than the viewport of the device (a windowor other viewable area on the screen) and require the user to scroll toview the entire page. An example of such a page is a blog, whichtypically is a relatively long page with a series of stories, the mostrecent of which are on top. When the page is loaded, only the imageswithin the viewport (the visible portion of the client window) can beviewed. However, most client network application such as browsersdownload all of the images on the page before the page is ready. Thismay slow down page performance waste bandwidth for images that may neverbe seen (e.g., if the user does not scroll down to actually view theimages that are not on the viewport).

Most client network applications create an image placeholder for eachsingle image that is referenced in a web page. Most images areexternally sourced and downloaded by the client network application andare displayed in the location of the corresponding image placeholders.If an image cannot be displayed (e.g., an error occurred when the imagewas attempted to be downloaded), most client network applicationsdisplay a broken image or other error display in the location of thecorresponding image placeholder.

SUMMARY

A method and apparatus for automatically optimizing the loading ofimages in a cloud-based proxy service is described. In one embodiment, arequest is received at a proxy server for a web page, the requestoriginating from a client network application of a client device. Therequested web page includes multiple references to multiple images. Theproxy server retrieves the requested web page. The proxy server modifiescode of the retrieved web page such that the client network applicationwill not, for each one of images, request that image until the locationwhere that image is to be displayed is within a viewport of the clientnetwork application or within a defined distance from the viewport ofthe client network application. The proxy server transmits the modifiedweb page to the client device. The client device receives the modifiedweb page and determines a size of the viewport of the client networkapplication. For each of the image references, the client devicedetermines a location in the web page where the corresponding image isto be displayed. For each and only those of the image references whosedetermined location in the web page where the corresponding image is tobe displayed is within the viewport or within a defined distance fromthe viewport, the client device transmits a request for that image,receives that image, and then displays that image.

In another embodiment, a request is received at a proxy server for a webpage, the request originating from a client network application of aclient device. The proxy server retrieves the requested web page, whichincludes at least one reference to an image. The proxy server modifiescode of the retrieved web page such that when the client networkapplication issues a request for the image, that request will include anindication of a set of one or more requested dimensions for the image.The proxy server transmits the modified web page to the client device.The client device receives the modified web page and determines adisplay size of the image. The client device transmits a request for theimage, the request including an indication of a set of one or morerequested dimensions for the image that is equal or substantially equalto the determined display size. The request is received at the proxyserver. The proxy server determines whether it has an image that issubstantially equal to the requested dimensions. If it does, it returnsthe image with those dimensions to the requesting client device. If itdoes not, the proxy server retrieves the image and resizes it based onthe requested dimensions. The proxy server then returns the resizedimage to the requesting client device. The proxy server may store theresized image such that future requests, which may be received fromdifferent client devices, that include an indication of similarrequested dimensions will be locally served from the proxy serverwithout again being resized.

BRIEF DESCRIPTION OF THE DRAWINGS

The invention may best be understood by referring to the followingdescription and accompanying drawings that are used to illustrateembodiments of the invention. In the drawings:

FIG. 1 illustrates an exemplary system for a cloud-based proxy serviceaccording to one embodiment;

FIG. 2 is a flow diagram that illustrates exemplary operations performedon a proxy server for deferred image loading according to oneembodiment;

FIG. 3 is a flow diagram that illustrates exemplary operations formodifying a page such that the client network application will not (atleast initially) load at least certain images of the page according toone embodiment;

FIG. 4 is a flow diagram that illustrates exemplary operations performedby one or more client-side scripts for deferred loading of imagesaccording to one embodiment;

FIG. 5 is a flow diagram that illustrates exemplary operations that areperformed by the set of client-side scripts when causing the clientnetwork application to request the image according to one embodiment;

FIG. 6A illustrate an example of one embodiment of deferred imageloading;

FIG. 6B illustrates the continuation of the example illustrated in FIG.6A;

FIG. 7 is a flow diagram that illustrates exemplary operations performedon a proxy server for auto-resizing of images according to oneembodiment;

FIG. 8 is a flow diagram that illustrates exemplary operations performedon a client device for causing image(s) referenced in a web page to berequested by the client network application with a set of one or moredimensions according to one embodiment;

FIG. 9 is a flow diagram that illustrates exemplary operations performedby a set of one or more client-side scripts for determining the displaysize of the image according to one embodiment;

FIG. 10 is a flow diagram illustrating exemplary operations performed bya proxy server for performing auto-resizing of images according to oneembodiment;

FIG. 11 is an exemplary interface for the control servers that allows acustomer to enable or disable the deferred image loading and/or imageauto-resizing functionality described herein, according to oneembodiment; and

FIG. 12 illustrates an exemplary format of a computer system of devicesof the cloud-based proxy service according to one embodiment.

DESCRIPTION OF EMBODIMENTS

In the following description, numerous specific details are set forth.However, it is understood that embodiments of the invention may bepracticed without these specific details. In other instances, well-knowncircuits, structures and techniques have not been shown in detail inorder not to obscure the understanding of this description. Those ofordinary skill in the art, with the included descriptions, will be ableto implement appropriate functionality without undue experimentation.

References in the specification to “one embodiment,” “an embodiment,”“an example embodiment,” etc., indicate that the embodiment describedmay include a particular feature, structure, or characteristic, butevery embodiment may not necessarily include the particular feature,structure, or characteristic. Moreover, such phrases are not necessarilyreferring to the same embodiment. Further, when a particular feature,structure, or characteristic is described in connection with anembodiment, it is submitted that it is within the knowledge of oneskilled in the art to effect such feature, structure, or characteristicin connection with other embodiments whether or not explicitlydescribed. In the following description and claims, the terms “coupled”along with its derivatives, may be used. “Coupled” is used to indicatethat two or more elements, which may or may not be in direct physical orelectrical contact with each other, co-operate or interact with eachother.

A method and apparatus for automatically optimizing the loading ofimages is described. In one embodiment, the loading of the images isautomatically managed in a cloud-based proxy service that includes oneor more proxy servers that are situated between the end users (e.g.,users using a browser or other client network application to accessnetwork content) and origin server(s) that host the network content. Inthe cloud-based proxy service, requests for network resources (e.g., webpages such as HTML documents, images, word processing documents, PDFfiles, movie files, music files, or other computer files) are receivedat a proxy server of the cloud-based proxy service. The proxy server maymodify the requested resource prior to transmitting a response to therequesting client (if the network resource is not stored in a locallyavailable cache, the proxy server may transmit a request to theappropriate origin server for the network resource). As will bedescribed in greater detail later herein, the proxy server may cause theloading of images in a page to be optimized. In one embodiment, thecloud-based proxy service is available as a service over the Internetand does not require customers (e.g., domain owners and/or personnelworking on behalf of domain owners) to install additional hardware orsoftware in order to support the service. In one embodiment, thecloud-based proxy service is provisioned through a change in Domain NameSystem (DNS) records of the customers.

The proxy server is configured to automatically cause image loading tobe optimized for a client device. For example, in one embodiment, theloading of the images whose corresponding image placeholders are in theviewport of the client are prioritized over images whose correspondingimage placeholders are not in the viewport. The other image(s) whosecorresponding placeholder(s) of the page that are not in the viewportmay be loaded as they are needed (e.g., when they become in theviewport) or as there are spare network resources available.Prioritizing the loading of the images whose corresponding imageplaceholders that are in the viewport of the client is sometimesreferred herein as deferred image loading.

In one embodiment, in addition to or in lieu of deferred image loading,the images are automatically optimized to a size appropriate for howthey are set as being displayed and/or the viewport of the requestingdevice. This is sometimes referred herein as image auto-resizing. As anexample of image auto-resizing, if an image that is 1000 pixels by 1000pixels is set to be displayed at 100 pixels by 100 pixels, the image maybe automatically resized and delivered to the visitors at theappropriate size (e.g., 100 pixels by 100 pixels). As another example,if the size of the viewport of a device is 960 by 640 pixels (which is acommon size for mobile devices), a background image that is 2000 pixelswide will be automatically downsized so that more pixels are notdelivered to the visitor than can be displayed.

In one embodiment, the management of images may be different dependingon the connection of the client. For example, the management of imagesmay be different for visitors connecting over a mobile operator'snetwork (where bandwidth is typically limited) versus visitorsconnecting over a wired or WiFi network (where bandwidth is less of aconcern). By way of example, in one embodiment, if a visitor isconnecting over a mobile operator's network (e.g., 2G, 3G, 4G), only theimages that are in the viewport will be delivered to the visitors;whereas if a visitor is connecting over a wired or WiFi network, theimages in the viewport will be prioritized and the other images will beloaded in the background (which may be prioritized based on where theyappear in the page).

In one embodiment, the deferred image loading and/or auto-resizingdescribed herein are provided through the cloud-based proxy service thatis available on the Internet as a service and does not require customersto install additional hardware or software in order for the deferredimage loading and/or the auto-resizing to be performed. In addition, thedeferred image loading and/or auto-resizing can be performedautomatically without requiring the user to change any of their HTML.

FIG. 1 illustrates an exemplary system for a cloud-based proxy serviceaccording to one embodiment. The cloud-based proxy service illustratedin FIG. 1 includes a set of proxy server(s) 120 that are situatedbetween the client computing devices 110A-I and the origin servers130A-N. In one embodiment, the proxy server(s) 120 are reverse proxyservers. Certain network traffic is received and processed through theset of proxy server(s) 120. For example, web traffic (e.g., HTTPrequests/responses, HTTPS requests/responses, etc.) for domains of theorigin servers 130A-N may be received and processed at the proxyserver(s) 120. In one embodiment, the domain owners 135A-L are customersof the cloud-based proxy service and certain network traffic for theirwebsites are received at processed at the proxy server(s) 120.

The client devices 110A-I are computing devices (e.g., laptops,workstations, smartphones, palm tops, mobile phones, tablets, gamingsystems, set top boxes, etc.) that are capable of transmitting andreceiving network traffic. Each of the client devices 110A-I executes aclient network application that is capable of transmitting networktraffic and loading network traffic. For example, the client networkapplication may be a web browser or other application that can accessnetwork resources (e.g., web pages, images, word processing documents,PDF files, movie files, music files, or other computer files).

The origin servers 130A-N are computing devices that serve networkresources (e.g., web pages, images, word processing documents, PDF filesmovie files, music files, or other computer files). Although notillustrated in FIG. 1, it should be understood that the networkresources of the origin servers 130A-N may be stored separately from thedevice that responds to the requests.

The cloud-based proxy service may provide different services forcustomers (e.g., the domain owners 135A-L). By way of example, thecloud-based proxy service may provide services including protectingagainst Internet-based threats (e.g., proactively stopping botnets,cleaning viruses, trojans, and worms, etc.), providing performanceservices for customers (e.g., acting as a node in a content deliverynetwork (CDN) and dynamically caching customer's files closer tovisitors, page acceleration, content optimization services, etc.),and/or other services. In one embodiment and as described in greaterdetail later herein, the cloud-based proxy service also provides imageloading optimization (e.g., deferred image loading and/or auto-resizing)for the domain owners 135A-L.

Generally speaking, the proxy server(s) 120 receive certain networktraffic from the client devices 110A-I that are destined for one of theorigin servers 130A-N. For example, a proxy server 120 may receiverequests for an action to be performed on an identified resource of anorigin server (e.g., an HTTP GET request, an HTTP POST request, otherHTTP request methods, or other requests to be applied to an identifiedresource on an origin server) from the client devices 110A-I. Asillustrated in FIG. 1, the incoming traffic 154 is received at one ofthe proxy server(s) 120.

The proxy server(s) 120 analyze the incoming traffic 154 and take one ormore actions on the incoming traffic. In some embodiments, the incomingtraffic 154 is received at a particular proxy server 120 as a result ofa DNS request 150 for a domain of one of the domain owners 135A-Lresolving 152 to an IP address of the proxy server 120. By way ofexample, DNS record(s) for the domain “example.com” may resolve to an IPaddress of a proxy server 120. In some embodiments, multiple domainsthat may be owned by different domain owners may resolve to the sameproxy server 120 (e.g., the same IP address or a different IP address ofthe proxy server 120).

By way of a specific example, the incoming traffic 154 may be a requestfor a web page which includes a set of one or more images. A proxyserver 120 that receives a request for a page determines whetherdeferred image loading and/or image automatic resizing is enabled forthat web page. The proxy server 120 may retrieve the requested page fromits cache if available and it has not expired. Alternatively, the proxyserver 120 may issue a request to the appropriate origin server 130 forthe page (part of the outgoing traffic 156). The proxy server 120receives incoming traffic 158 from the origin server (e.g., an HTTPresponse with the requested content).

After retrieving the requested page and after determining that deferredimage loading and/or image automatic resizing is enabled for that page,the proxy server 120 modifies the retrieved page to cause the loading ofthe images to be deferred and/or cause the size of the images that areloaded to be optimized for the page and device. The proxy server(s) 120transmit responses to the client devices 110A-I in the outgoing traffic159.

The DNS system 140 is used to refer to the DNS system as a whole andincludes multiple DNS servers to resolve DNS requests. As illustrated,the DNS system 140 includes the authoritative name server 142, which maybe an authoritative name server for the cloud-based proxy service andthe domains hosted at the origin servers 130A-N. It should be understoodthat the DNS system 140 may include more DNS servers (e.g., preferreddomain servers, top-level domain name servers, or other domain servers)than illustrated. It should also be understood that there may bemultiple authoritative web servers for the service and they may begeographically distributed. In one embodiment, the authoritative nameservers for each the domains have been changed to the authoritative nameserver 142, which is associated with the service. It should beunderstood that the backup authoritative name servers serving thedomains may also be changed. In one embodiment, the zone file records144 for the domains of the domain owners 135A-L are changed such thatDNS resolution requests for those domains resolve to the proxy server(s)120.

Although not illustrated in FIG. 1, in one embodiment the cloud-basedproxy service includes multiple nodes (referred herein as “proxy servicenodes”). Each proxy service node may include any of one or more proxyservers, one or more control servers, one or more DNS servers (e.g., oneor more authoritative name servers), and one or more other pieces ofnetworking equipment (e.g., one or more routers, switches, hubs, etc.).The proxy service node may be part of the same physical device ormultiple physical devices. For example, the proxy server(s), controlserver(s), and DNS server(s) may be virtual instances running on thesame physical device or may be separate physical devices. Each proxyservice node may be part of a data center or a collocation site.

The cloud-based proxy service also includes the control server(s) 125which are operated by the service. In one embodiment, the controlserver(s) 125 provide a set of tools and interfaces for the domainowners 135A-L and is accessible over the Internet. For example, thecontrol server(s) 125, among other things, allow the customers 135A-L toregister for the cloud-based proxy service and configure 182 the imageloading settings. In some embodiments, the domain owners 135A-L registerfor the cloud-based proxy service including changing their authoritativename server(s) to authoritative name server(s) of the service (theservice may specify to the domain owners the name server(s) to use).Although not illustrated, the control server(s) 125 may provide aninterface (e.g., a website) for the domain owners 135A-L to register forthe cloud-based proxy service and possibly change their authoritativename server(s) and DNS record(s). In addition, the IP address(es) thatresolve to their origin server(s), which host content of their domain,are changed to point to a proxy server 120, which are typically chosenby the service. In other embodiments, individual DNS records are changedto point to a proxy server 120 (or point to other domain(s) that pointto a proxy server of the service). For example, a DNS record of a domainowner can be changed to point to a CNAME that corresponds with a proxyserver 120. The control server(s) 125 may transmit a DNS update 185 tothe DNS system 140 to change the DNS record(s) of a domain owner.Regardless of the embodiment, traffic from visitors that are directed toa customer's domain is received at one of the proxy server(s) 120.

Upon configuring image loading for their domain (e.g., deferred imageloading and/or image automatic resizing), the control server 125transmits the appropriate setting 183 to the proxy server(s) 120. Thissetting may be stored in the proxy server(s) 120 and accessed whenreceiving a request for a page of their domain.

Deferred Loading of Images

After a page is retrieved, the proxy server 120 modifies the page forautomatically optimizing image loading. In one embodiment, if deferredimage loading is enabled for the requested network resource (or enabledfor the domain of the requested network resource), the proxy server 120modifies the page such that the loading of the image(s) whosecorresponding image placeholder(s) are in the viewport and optionally inclose proximity to the viewport will be prioritized over those image(s)whose corresponding image placeholder(s) are not in the viewport and/ornot in close proximity to the viewport. The proxy server 120 may alsomodify the page such that the other image(s) of the page whosecorresponding image placeholder(s) that are not in the viewport may beloaded as they are needed (e.g., when they are scrolled into theviewport) or as there are spare network resources available.

In a specific example, the proxy server 120 parses the retrieved pageand analyzes its image tags, and modifies the image tags such that theimage will not be displayed and the client network application will notrequest the image (at least not initially—the client network applicationmay request the image when its corresponding image placeholder comesinto the viewport or in the background if there are spare networkresources available). In one embodiment, the image objects remain in theDOM (that is, they are not removed from the DOM). For example, the proxyserver 120 changes the src attribute (which specifies the location ofthe image—often a URL) such that the client network application will notissue a request for the image, while maintaining the informationspecifying the location of the image. For example, the proxy server 120may modify the name of the src attribute to a value that is unrecognizedby the client network application. By way of example, the proxy server120 may prepend “data-cf” to the “src” attribute in the HTML (e.g.,modify “src” to “data-cfsrc”) of the retrieved page. This causes theclient network application to not make a request for that image as itdoes not recognize “data-cfsrc”. Of course this is just an example andthere are other ways to prevent the client network application frommaking the request for the image.

If the image tag has a style attribute, then the proxy server 120changes the style attribute such that the client network applicationwill not apply the style while still maintaining the information of thestyle (e.g., that style will be reapplied when the image is ready to beloaded). For example, the proxy server 120 may modify the name of thestyle attribute to a value that is unrecognized by the client networkapplication. For example, the proxy server 120 may prepend “data-cf” tothe “style” attribute in the HTML (e.g., modify “style” to“data-cfstyle”). This causes the client network application to not applythe style. Of course this is just an example and there may be other waysto prevent the client network application from applying the style.

The proxy server 120 also causes the image and/or the image placeholderto not be displayed while maintaining an image object in the DOM. In oneembodiment, the proxy server 120 adds a style attribute to the image tagthat causes the client network application to not display the imageplaceholder. For example, the proxy server 120 may add a style with thefollowing value: style=“display:none;”. As another example, the proxyserver 120 may add a style with the following value:style=“visibility:hidden;”. As another example, the proxy server 120 mayadd a style with the following value:style=“display:none;visibility:hidden;”. For purposes of explanation,the added style attribute is sometimes referred herein as the “nullstyle attribute.” In another embodiment, the proxy server 120 may causea different image to be initially loaded by the client networkapplication. This different image may not be visible to the user (e.g.,the image may be a transparent image that the client network applicationrenders in the background color where the image is to be placed). Thedifferent image may be of a small size (e.g., 1 by 1 pixels), which maybe stretched according to the height and/or width of the original image.By way of example, the proxy server 120 may add a source attribute tothe image tag that specifies the location of the different image, andmay further have the width and/or height set the same as the originalimage. The proxy server 120 may alternatively add a source attribute tothe image tag that embeds the image data inline into the html (e.g., addthe image as a data Uniform Resource Identifier (URI) object), and mayfurther set the width and/or height to be the same as the originalimage.

In some embodiments, the proxy server 120 inserts a set of one or moreclient-side scripts (e.g., JavaScript) and/or reference(s) to a set ofone or more client-side scripts that, when executed by the clientnetwork application, restore the source attribute (and style attributeif one was originally included) for the image, when the correspondingimage placeholder is located in the viewport or with a defined distanceto the viewport. Since some client network applications may not becapable of executing client-side scripts or have disabled client-sidescripts, the proxy server 120 may wrap the original image tag in anoscript tag. In this way, if the client network application does notsupport client-side scripts or has them disabled, the images will beloaded as they would normally.

In one embodiment, the proxy server 120 causes the deferred loading ofimages to be performed on only those images that belong to the samedomain as the requested page. For example, if the page is example.com;in this embodiment the proxy server 120 causes the deferred loading ofimages to be performed only on images of example.com (e.g.,example.com/image.gif); not other domains (e.g., images of the domainexample2.com). In another embodiment, the proxy server 120 causes thedeferred loading of images to be performed only on those images that arelocated on domains that are customers of the cloud-based proxy service.For example, if the image source is a third party source that is not ona domain that is a customer of the cloud-based proxy service, then inone embodiment the proxy server 120 does not modify that image tag tocause its loading to be deferred.

As previously described, in one embodiment, the proxy server 120 addsone or more client-side scripts and/or a reference to one or moreclient-side scripts that, when executed by the client networkapplication, prioritizes the loading of the image(s) whose correspondingimage placeholder(s) are in the viewport of the client networkapplication or within a defined distance of the viewport over theimage(s) whose corresponding image placeholder(s) are not in theviewport (if any). In one embodiment, the client-side script(s) attemptsto determine the size of the viewport, the type of client device (thismay help determine the size of the screen of the device), the type ofnetwork connection (e.g., over a mobile operator's network (wherebandwidth is typically limited), over a wired or WiFi network (wherebandwidth is typically less of a concern)), and/or the location in thepage where the images would be displayed with respect to the viewport.

In one embodiment, when the client side script determines that thelocation where the image is to be displayed is in the viewport or iswithin a threshold distance amount from the viewport (e.g., is less thanX number of pixels from the viewport), the client-side script performs anumber of actions to cause the client network application to request anddisplay the image. For example, the client-side script rewrites thesource attribute to cause the client network application to make arequest for the image (e.g., by removing “data-cf” from “data-cfsrc”).If a style attribute for the image was originally included in the HTML(and modified by the proxy server 120), the client-side script rewritesthe style attribute according to the original style attribute (e.g., byremoving “data-cf” from “data-cfstyle”). The client-side script alsoremoves the null style attribute, which causes the image (if retrieved)to be displayed.

In one embodiment, if the client is connecting through a mobileconnection (through a mobile operator's network where bandwidth istypically limited), the client-side script causes only the image(s)whose corresponding image placeholder(s) are in the viewport or that arewithin a certain distance from the viewport to be loaded; whereas if theclient is not connecting through a mobile connection (e.g., a wirednetwork, WiFi, etc.), the image(s) whose corresponding imageplaceholder(s) are in the viewport and/or within a certain distance fromthe viewport are prioritized and the other images are loaded in thebackground (which may be prioritized based on where they appear in thepage).

FIG. 2 is a flow diagram that illustrates exemplary operations performedon a proxy server for deferred image loading according to oneembodiment. The operations of this and other flow diagrams will bedescribed with reference to the exemplary embodiments of FIG. 1.However, it should be understood that the operations of the flowdiagrams can be performed by embodiments of the invention other thanthose discussed with reference to FIG. 1, and the embodiments of theinvention discussed with reference to FIG. 1 can perform operationsdifferent than those discussed with reference to the flow diagrams.

At operation 210, a proxy server 120 receives a request for a page(e.g., an HTML page) that originates from a client network applicationof a client device. The request may be received as a result of a DNSrequest for the domain of the page resolving to an IP address of theproxy server 120. Next, at operation 215, the proxy server 120determines that deferred image loading is enabled for the requestedpage. In one embodiment, the proxy server 120 accesses a set of one ormore page rules for the domain of the requested page to determinewhether deferred image loading has been enabled. Enabling deferred imageloading will be described in greater detail later herein. In someembodiments the operation of 215 is optional (e.g., the deferred imageloading is applied to every page). Flow then moves to operation 220.

At operation 220, the proxy server 120 retrieves the requested page. Ifthe requested page is available in the proxy server's cache and it hasnot expired, the proxy server 120 may retrieve the requested page fromits cache. The proxy server 120 may also retrieve the requested pagefrom the origin server (e.g., transmit a request to the origin serverfor the page and receive a response from the origin server that includesthe page). Flow then moves to operation 225.

At operation 225, the proxy server 120 modifies the page to prioritizethe loading of the images of the page whose corresponding imageplaceholders are in the viewport or within a defined distance to theviewport. The defined distance to the viewport is a value that is smallenough such that the visitor may scroll the viewport to view that image.For example, the defined distance may be within 100 pixels of theviewport. The defined distance may be predefined in one embodiment(e.g., hard coded in the code of the page) or determined based on thesize of the viewport of the client network application.

As an example of modifying the page, the proxy server 120 may modify theimage tags such that they will not (at least initially) be requested bythe client network application. In addition, the proxy server 120 mayalso add one or more client-side scripts (e.g., JavaScript) and/orreferences to one or more client-side scripts that, when executed by theclient network application, cause the images to be loaded when thecorresponding image placeholders are located within the viewport of theclient network application or within a defined threshold distance fromthe viewport (e.g., within 100 pixels from the viewport).

Flow then moves to operation 230 where the proxy server 120 transmitsthe modified page to the requesting client device. The proxy server 120may also store the modified page in its cache such that upon receiving asubsequent request for the page (from the same client device or from adifferent client device), the proxy server 120 may transmit the modifiedpage to the requesting client device without having to modify the pageagain.

FIG. 3 is a flow diagram that illustrates exemplary operations formodifying a page such that the client network application will not (atleast initially) load at least certain images of the page according toone embodiment. At operation 310, the proxy server 120 begins to parsethe page in an attempt to locate the image tags in the page (e.g., “<img. . . />”). If an image tag is detected at operation 315, then flowmoves to operation 320, otherwise flow moves to operation 350 where theoperations of FIG. 3 end.

At operation 320, if the parser detects that there is a style attributewithin the image tag, then flow moves to operation 325; otherwise flowmoves to operation 330. At operation 325, the style attribute ismodified to cause the client network application (e.g., the browser) tonot apply the style, while maintaining the value of the style. The valueof the style is maintained so that it can be reapplied when/if the imageis to be loaded. For example, the proxy server 120 may prepend “data-cf”to the “style” attribute in the HTML (e.g., modify “style” to“data-cfstyle”), which causes the client network application to notapply the style. Flow moves from operation 325 to operation 330.

At operation 330, a style attribute is added to the image tag to causethe client network application not to display the image placeholder. Forexample, “style=“display:none;visibility:hidden;” may be added to theimage tag to cause the client network application not to display theimage placeholder. As another example, the proxy server 120 may add astyle with the following value: style=“display:none;”. As anotherexample, the proxy server 120 may add a style with the following value:style=“visibility:hidden;”. Flow moves from operation 330 to operation335.

In another embodiment, instead of adding a style attribute to the imagetag to cause to cause it not to be displayed, the proxy server 120 maycause a different image to be initially loaded by the client networkapplication and displayed in the original image's placeholder. Thisdifferent image may not be visible to the user (e.g., the image may be atransparent image that the client network application renders in thebackground color where the image is to be placed). The different imagemay be of a small size (e.g., 1 by 1 pixels), which may be stretchedaccording to the height and/or width of the original image. By way ofexample, the proxy server 120 may add a source attribute to the imagetag that specifies the location of the different image, and may furtherhave the width and/or height set the same as the original image. Theproxy server 120 may alternatively add a source attribute to the imagetag that embeds the image data inline into the html (e.g., add the imageas a data Uniform Resource Identifier (URI) object), and may further setthe width and/or height to be the same as the original image.

At operation 335, the source attribute of the image tag is modified tocause the client network application to not issue a request to thesource of the image, while maintaining the information that specifiesthe location of the image. For example, the proxy server 120 may modifythe name of the src attribute to a value that is unrecognized by theclient network application. By way of example, the proxy server 120 mayprepend “data-cf” to the “src” attribute in the HTML (e.g., modify “src”to “data-cfsrc”), which causes the client network application to notmake the request since it does not recognize “data-cfsrc”. Flow movesfrom operation 335 back to operation 310 where the page continues to beparsed.

Although not illustrated in FIG. 340, in some embodiments the proxyserver also maintains the original image tag but wraps it within anoscript tag. In this way, if a client network application does notsupport client-side scripts or has them disabled, the images will bedisplayed as they would normally. In such an embodiment, the proxyserver may copy the content of the original image tag and operate on thecopied image tag when making the above modifications. Also, in such anembodiment, the image tag that has been modified for deferred imageloading may be placed in the HTML directly before or directly after theoriginal image tag that has been wrapped in a noscript tag.

In one embodiment, the proxy server defers the loading of only thoseimages that have a source on the same domain as the requested page. Insuch an embodiment, after detecting an image tag, the proxy serverdetermines whether the source of the image tag is of the same domain asthe requested page. If they are the same, then the operations describedwith respect to operations 320 to 335 are performed. If they are not thesame, then those operations would not be performed.

In another embodiment, the proxy server defers the loading of only thoseimages that have a source with a domain that resolves to a proxy serverof the cloud-based proxy service, even if that domain is different thanthe domain as the requested page. In such an embodiment, after detectingan image tag, the proxy server determines whether the source of theimage tag is of a domain that resolves to a proxy server of thecloud-based proxy service. For example, the proxy server may have a listof the domains that resolve to a proxy server of the cloud-based proxyservice. If the domain resolves to a proxy server of the cloud-basedproxy service, then the operations described with respect to operations320 to 335 are performed. If the domain does not resolve to a proxyserver of the cloud-based proxy service, then those operations would notbe performed.

In another embodiment, the proxy server defers the loading of each ofthe images, regardless of the source of the image.

In addition to modifying the image tags such that they will not (atleast initially) be requested by the client network application, theproxy server also adds one or more client-side scripts (e.g.,JavaScript) and/or references to one or more client-side scripts that,when executed by the client network application, causes the images to beloaded when the corresponding image placeholders are located in theviewport or within a defined distance to the viewport. For example, theclient-side script(s), when executed by the client network application,detects the location of the image placeholders (at least for thoseimages whose loading has been deferred) with respect to the viewport.When an image placeholder is located within the viewport or, in someembodiments within a certain distance from the viewport (e.g., within100 pixels of the viewport), the client-side script(s) perform a numberof actions to cause the client network application to request anddisplay the corresponding image. For example, the client-side script(s)rewrite the source attribute to cause the client network application tomake a request for the image (e.g., by removing “data-cf” from“data-cfsrc”). If a style attribute for the image was originallyincluded in the HTML (and modified by the proxy server 120), theclient-side script(s) rewrite the style attribute according to theoriginal style attribute (e.g., by removing “data-cf” from“data-cfstyle”). The client-side script(s) also remove the null styleattribute, which causes the image (if retrieved) to be displayed.

In some embodiments, the client-side script(s) only cause the imageswhose corresponding image placeholders are located in the viewport andoptionally those that are within a certain distance from the viewport tobe loaded (e.g., if the requesting client device is connecting over amobile operator's network such as 3G or 4G). Thus, in these embodiments,only when an image placeholder scrolls into the viewport or within acertain distance from the viewport, the client-side script(s) will causethe client network application to request and download the correspondingimage. In other embodiments, for example if the requesting client deviceis not connecting over a mobile operator's network (e.g., a WiFiconnection, a wired connection, etc.), the client-side script(s)prioritize the loading of the images whose corresponding imageplaceholders are currently located in the viewport and optionally thosethat are within a certain distance from the viewport; and causes otherimage(s) (if any) to be loaded in the background when bandwidth isavailable.

FIG. 4 is a flow diagram that illustrates exemplary operations performedby one or more client-side scripts for deferred loading of imagesaccording to one embodiment. The operations described with reference toFIG. 4 are performed by the set of one or more deferred loadingclient-side scripts that are either included in the modified page thatis transmitted to the requesting client device and/or referenced in themodified page.

At operation 410, the set of client-side scripts determine whether animage placeholder is in the viewport or in some embodiments if it iswithin a defined distance from the viewport. In order to determine this,the current size of the viewport of the client device is determined. Insome embodiments the set of client-side scripts perform a series ofchecks to determine the size of the viewport (the viewport width andheight variables). These checks may include determining whether there isan innerWidth variable defined in the window. If there is, theinnerWidth and innerHeight may be used for the viewport width and heightvariables. If there is not, the client-side script(s) may determinewhether the clientWidth (or clientHeight) variable is defined for thedocument. If there is, the clientWidth and clientHeight variables areused for the viewport width and height variables. If there is not, theclient-side script(s) may read the body element and read the clientWidthand clientHeight variables and use those for the viewport width andheight variables.

In addition to determining the size of the viewport, the set ofclient-side scripts also determine the location of the imageplaceholders with respect to the viewport. For example, the position ofthe scrollbar is determined and from that value, the width of the topborder of the image placeholder is subtracted. That value is then addedto the height of the viewport (e.g., as determined by the viewportheight variable). The resulting value is subtracted from the top of thebounding rectangle of the image placeholder. The resulting value is apixel distance from the top of the image placeholder to the viewport.

If the image placeholder is not in the viewport or within a certaindistance from the viewport, then flow moves to operation 420 (which isoptionally performed in some embodiments). If the image placeholder isin the viewport or within a certain distance from the viewport, thenflow moves to operation 415 where the client-side scripts cause theclient network application to request the corresponding image. Forexample, the set of client-side scripts rewrite the source attribute tocause the client network application to make a request for the image(e.g., by removing “data-cf” from “data-cfsrc”). If a style attributefor the image was originally included in the HTML (and modified by theproxy server 120), the set of client-side scripts rewrite the styleattribute according to the original style attribute (e.g., by removing“data-cf” from “data-cfstyle”). The set of client-side scripts alsoremove the null style attribute, which causes the image (if retrieved)to be displayed. Flow moves from operation 415 back to operation 410.

FIG. 5 is a flow diagram that illustrates exemplary operations that areperformed by the set of client-side scripts when causing the clientnetwork application to request the image according to one embodiment.For example, the operations described with reference to FIG. 5 may beperformed as part of the operation 415 of FIG. 4. At operation 510, theset of client-side scripts determine whether the style attribute of theimage that is to be requested was modified to cause the client networkapplication to not apply the style. By way of example and notlimitation, if the proxy server 120 modified the style attribute tocause the client network application to not apply the style whilemaintaining the value of the style by prepending “data-cf” to the“style” attribute (e.g., “style” was changed to “data-cfstyle”), the setof client-side scripts analyzes the image tag to determine whether thatspecific attribute name (data-cfstyle) is included in the image tag. Ifthe original style attribute of the image was modified, then flow movesto operation 515, otherwise flow moves to operation 520.

At operation 515, the set of client-side scripts restore the modifiedstyle attribute of the image to its original value. For example, the setof client-side scripts may restore the name of the style attribute to“style” (e.g., remove “data-cf” from “data-cfstyle”). Next, flow movesto operation 520 where the set of client-side scripts remove the styleattribute that was added to the image tag to cause the image placeholderto not be displayed (the null style attribute). Next, flow moves tooperation 525 where the set of client-side scripts restore the sourceattribute of the image tag to its original value. By way of example, ifthe proxy server 120 modified the name of the source attribute (e.g., byprepending “data-cf” to “src”), the set of client-side scripts restorethe original name of the source attribute (e.g., by removing “data-cf”from “data-cfsrc”).

As will be described in greater detail later herein, the set ofclient-side scripts may also request the image to have a particular sizebased on how the image is used on the page and the size of the viewport.For example, the set of client-side scripts may determine that an imageis 1000 pixels by 1000 pixels, but is set to be displayed at 100 pixelsby 100 pixels. The set of client-side scripts may cause the clientnetwork application to request the image have a smaller size (e.g., 100pixels by 100 pixels). In response to this request, the proxy server orother device in the service may automatically resize the imageaccordingly and deliver the resized image, or retrieve a smaller sizedversion of the image (e.g., from cache) and deliver the resized image tothe client device. As another example, if the set of client-side scriptsdetermine that the size of the viewport of a device is 960 by 640 pixels(which is a common size for mobile devices), but a background image is2000 pixels wide, the set of client-side scripts may cause the clientnetwork application to request the background image to be of a size nolarger than can be displayed by the device.

In some embodiments, even if the image placeholder is not in theviewport or within a defined distance from the viewport, the set ofclient-side scripts cause the client network application to request theimage when there is available bandwidth. In one embodiment, availablebandwidth depends on whether the client is connecting through a mobileoperator's network or through a different type of network (e.g., wired,WiFi, etc.).

At operation 420, the set of client-side scripts determine whether theclient device is connecting through a mobile connection (e.g., 2G, 3G,4G, etc.). The set of client-side scripts may determine the connectionof the requesting client device by examining the navigator property,which some mobile browsers use to reveal information relating to theconnection the browser is using (e.g., WiFi, 2G, 3G, 4G, etc.). If theclient is connecting through a mobile connection, then flow moves backto operation 410. If the client is not connecting through a mobileconnection (e.g., the client is connecting via WiFi, a wired network,etc.), then flow moves to operation 415 where the set of client-sidescripts cause the client network application to request the image. Thus,in this embodiment, if the client is connecting through a mobileconnection, then the client-side script(s) only cause the client networkapplication to request images when they are in the viewport oroptionally within a certain distance from the viewport (at least forthose images whose loading has been deferred).

FIGS. 6A and 6B illustrate one embodiment of deferred image loading.FIGS. 6A and 6B represents a client device rendering a page 605 (e.g.,an HTML page), which the client device has received from a proxy serversuch as the proxy server 120. The page 605 includes the imageplaceholders 610, 615, 620, and 625. The page may also include otherelements such as text, etc. The page 605 has been modified by the proxyserver such that the images of the page 605 will be loaded only whenthey are in the viewport. For example, the page 605 includes orreferences the deferred image loading script(s) 630. It should beunderstood that the deferred image loading script(s) 630 are notdisplayed. It should also be understood that the deferred image loadingexample illustrated in FIGS. 6A and 6B is exemplary and otherembodiments may load images when they are within a defined distance fromthe viewport and/or if there is available bandwidth.

The image placeholders 610 and 615 are currently within the viewport630. Accordingly, the deferred image loading script(s) 630 cause theclient network application to request and display the images thatcorrespond to the image placeholders 610 and 615. The image placeholders620 and 625 are not within the viewport 630. As a result, thosecorresponding images will not be requested. The image placeholders 620and 625 are represented with dashed lines to indicate that thecorresponding images have not been requested and downloaded.

In FIG. 6B, the user has scrolled down the page 605 such that the imageplaceholder 620 is now within the viewport 630. Accordingly, thedeferred image loading script(s) 630 cause the client networkapplication to request and display the image corresponding to the imageplaceholder 620. Since the image placeholder 625 is still not within theviewport 630, it will not be requested and displayed.

Auto-Resizing of Images

As previously described, in some embodiments, images are automaticallyoptimized to the size and resolution specific for the page and therequesting device (referred herein as auto-resizing). Auto-resizing ofimages may be performed independently of the deferred image loadingprocess described herein or in conjunction with the deferred imageloading process described herein.

In one embodiment, a set of one or more client-side scripts (theseclient-side script(s) may share at least some of the functionality ofthe client-side script(s) for deferred image loading) that are includedin the page and/or referenced in the page that includes the reference tothe image, cause the client-network application to request a size ofthat image according to the presented dimensions of the image and/or thesize of the viewport of the client device. As an example, these set ofclient-side scripts are included and/or referenced in the pageexample.com and cause an image located at example.com/image.gif to berequested with a size based on the presented dimensions of that imageand/or the current size of the viewport of the client device.

FIG. 7 is a flow diagram that illustrates exemplary operations performedon a proxy server for auto-resizing of images according to oneembodiment. At operation 710, a proxy server 120 receives a request fora page (e.g., an HTML page) from a client device. The request may bereceived as a result of a DNS request for the domain of the pageresolving to an IP address of the proxy server 120. Next, at operation715, the proxy server 120 determines that image auto-resizing is enabledfor the requested page. In one embodiment, the proxy server 120 accessesa set of one or more page rules for the domain of the requested page todetermine whether image auto-resizing has been enabled. Enabling imageauto-resizing will be described in greater detail later herein. In someembodiments the operation of 715 is optional (e.g., the automatic imageresizing is applied to every page). Flow then moves to operation 720.

At operation 720, the proxy server 120 retrieves the requested page. Ifthe requested page is available in the proxy server's cache and it hasnot expired, the proxy server 120 may retrieve the requested page fromits cache. The proxy server 120 may also retrieve the requested pagefrom the origin server (e.g., transmit a request to the origin serverfor the page and receive a response from the origin server that includesthe page). Flow then moves to operation 725.

At operation 725, the proxy server 120 modifies the page such that atleast some images will be automatically resized based on how thoseimages are used on the page and/or the size of the viewport. Forexample, the proxy server 120 may modify the code of the page such thatwhen the client network application issues a request for the image, thatrequest will include an indication of a set of one or more requesteddimensions for the image. The proxy server 120 may modify the image tagssuch that they will not (at least initially) be requested by the clientnetwork application. In one embodiment, the proxy server 120 may modifythe source attribute of the image tags in a similar way as describedwith respect to FIG. 3. In addition, the proxy server 120 also adds oneor more client-side scripts (e.g., JavaScript) and/or references to oneor more client-side scripts that, when executed by the client networkapplication, cause the client network application to request the imageswith dimensions based on how the image is set to be displayed and/or thesize of the viewport.

In one embodiment, only those images that are located on the same domainas the requested page may be automatically resized. In anotherembodiment, only those images that are located on the same domain as therequested page and other domains of customers of the service may beautomatically resized. In yet another embodiment, any image, regardlessof whether that image is located on a domain of a customer of theservice, may be automatically resized.

Flow then moves to operation 730 where the proxy server 120 transmitsthe modified page to the requesting client device. The proxy server 120may also store the modified page in its cache such that upon receiving asubsequent request for the page (from the same client device or from adifferent client device), the proxy server 120 may transmit the modifiedpage to the requesting client device without having to modify the pageagain.

FIG. 8 is a flow diagram that illustrates exemplary operations performedon a client device for causing image(s) referenced in a web page to berequested by the client network application with a set of one or moredimensions according to one embodiment. In one embodiment, theoperations described with reference to FIG. 8 are performed at least inpart by a set of one or more client-side scripts that are included inthe page being rendered by the client network application and/orreferenced in the page being rendered by the client network application.

In one embodiment, the operations described with reference to FIG. 8 areperformed only for those images that belong to the same domain as thepage. For example, if the requested page is example.com, in someembodiments the operations of FIG. 8 are performed only for images ofexample.com (e.g., example.com/image.gif).

At operation 805, a client network application receives a web page witha reference to an image. For example, the client network application ofa client device 110 may receive the web page from a proxy server 120.Next, at operation 810, an image is determined to be ready to berequested. For example, the client network application is ready to makea request for the image. In one embodiment, this request may have beendeferred as previously described herein (e.g., the image may be in theviewport or within a defined distance from the viewport).

Next, at operation 815, the set of client-side scripts determine thedisplay size of the image. The display size of the image refers to thedisplayed dimensions of the image. The set of client-side scripts maydetermine the display size of the image based on the presenteddimensions of the image (how the code of the page is configured todisplay the image) and/or the size of the viewport of the client networkapplication.

Next, at operation 820, the set of client-side scripts cause the clientnetwork application to request the image, where the request includes anindication of one or more requested dimensions for the image that areequal or substantially equal to the determined display size of theimage. For example, the set of client-side scripts cause the originalURL of the image to be rewritten to include a query string thatindicates the requested width and/or height of the image. By way of aspecific example, if the determined display size of the image located atwww.example.com/image.gif is 960 by 640, the client-side scripts maycause the client network application to request the image atwww.example.com/image.gif?_cfgetx=img.rx:960;img.rx:640. This request,which is received by the proxy server, notifies the proxy server of thesize of the image that should be returned to the client.

To cause the client network application to request the image, the set ofclient-side scripts may also rewrite the source attribute to cause theclient network application to make a request for the image (e.g., byremoving “data-cf” from “data-cfsrc”). If a style attribute for theimage was originally included in the HTML (and modified by the proxyserver 120), the client-side script rewrites the style attributeaccording to the original style attribute (e.g., by removing “data-cf”from “data-cfstyle”). The client-side script also removes the null styleattribute, which causes the image (if retrieved) to be displayed.

Next, at operation 825, the client network application receives theimage, which has a size that is equal or substantially equal to therequested dimensions. For example, the proxy server, upon receiving arequest for an image that includes an indication of requested dimensions(e.g., a query string that indicates the width and/or height of theimage that is being requested), returns the image with those dimensionsor an image that is within a certain range of those dimensions. Forexample, in one embodiment, the proxy server stores within its cache(e.g., when acting as a CDN), multiple versions of the image, each ofwhich having a different dimension. If there is an image that has therequested dimensions or is within a range of the requested dimensions(e.g., is within X number of pixels of the width and/or Y number ofpixels of the height), the proxy server returns that version of theimage to the requesting client device. If the proxy server does not havea copy of the image with the requested dimensions or within a range ofthe requested dimensions, then it will resize the image according to therequested dimensions. It should be understood that the proxy server mayissue a request to the origin server for the image if it does not havean image of a suitable size. Next, at operation 830, the client networkapplication displays the image in its corresponding image placeholder.

FIG. 9 is a flow diagram that illustrates exemplary operations performedby a set of one or more client-side scripts for determining the displaysize of the image according to one embodiment. For example, theoperations described with reference to FIG. 9 may be performed duringoperation 815 described with reference to FIG. 8.

Next, at operation 915, the set of client-side scripts attempt todetermine the presented dimensions for the image. The set of client-sidescripts may determine the presented dimensions for the image byperforming a set of one or more actions. For example, the set ofclient-side scripts may analyze the image tag to determine whether ithas the width and/or height set. As another example, the set ofclient-side scripts may examine the Cascaded Style Sheets (CSS) style(s)(if one exists) to determine how it is governing the size of the image.Flow then moves to operation 920.

At operation 920, a determination is made whether the presenteddimensions for the image were determined The presented dimensions forthe image may not be able to be determined if the width and/or heightattributes are not set in the image tag or CSS. If the presenteddimensions were not determined, then flow moves to operation 925 wherethe set of client-side scripts cause the client network application torequest the image. If the presented dimensions were determined, thenflow moves to operation 930.

At operation 930, the set of client-side scripts determine whether thepresented dimensions of the image is larger than the current size of theviewport. In one embodiment, the set of client-side scripts perform aseries of checks to determine the size of the viewport (the viewportwidth and height variables) as previously described herein. If thepresented dimensions of the image are larger than the current viewportsize, then flow moves to operation 935. If the presented dimensions ofthe image are smaller or equal to the current viewport size, then flowmoves to operation 940. At operation 940, the set of client-side scriptsset the display size of the image as the size of the presenteddimensions.

At operation 935, the set of client-side scripts set the display size ofthe image as less than or equal to the size of the viewport. Forexample, if the size of the viewport of the device is 960 by 640 pixels,but the background image is 2000 pixels wide, the set of client-sidescripts may set the display size of the image as having dimensions nogreater than 960 by 640.

The proxy server, upon receiving a request for an image that includes aquery string that indicates the width and/or height of the image that isbeing requested, returns the image with those dimensions or an imagethat is within a certain range of those dimensions. For example, in oneembodiment, the proxy server stores within its cache (e.g., when actingas a CDN), multiple versions of the image, each of which having adifferent dimension. By way of a specific example, the proxy server maystore a different version of the image for different known clientdevices (e.g., a different version for a mobile phone with known displaydimensions as compared to a different version for a tablet with knowndisplay dimensions). If there is an image that has the requesteddimensions or is within a range of the requested dimensions (e.g., iswithin X number of pixels of the width and/or Y number of pixels of theheight), the proxy server returns that version of the image to therequesting client device. If the proxy server does not have a copy ofthe image with the requested dimensions or within a range of therequested dimensions, then it will resize the image according to therequested dimensions. It should be understood that the proxy server mayissue a request to the origin server for the image if it does not havean image of a suitable size.

FIG. 10 is a flow diagram illustrating exemplary operations performed bya proxy server for performing auto-resizing of images according to oneembodiment. At operation 1010, the proxy server 120 receives a requestfor an image, the request indicating a particular width and/or height ofthe image. For example, the proxy server may receive a request for animage at the following URL example.com/image.gif may be requested withthe following URL example.com/image.gif?_cfgetx=img.rx=100;img.ry=100;which requests that the image image.gif should be approximately 100 by100 pixels. Flow then moves to operation 1015.

At operation 1015, the proxy server determines whether it has a cachedversion of the requested image with the requested dimensions oroptionally within a predefined range (e.g., within X number of pixels ofthe width (e.g., 50 pixels) and/or within Y number of pixels of theheight (e.g., 50 pixels)). If it does, then flow moves to operation 1020where the proxy server transmits a response to the requesting clientdevice with the retrieved image. If the proxy server does not have acached version of the requested image with the requested dimensions oroptionally within a predefined range, then flow moves to operation 1025where the proxy server retrieves the image. The proxy server mayretrieve the image from the origin server (e.g., by issuing a request tothe origin server for the image) if it does not have the image in itscache (if in its cache, the proxy server may retrieve the image from thecache). Flow then moves to operation 1025.

At operation 1025, the proxy server resizes the image according to therequested dimensions. Using the example above, if the original size ofthe image located at example.com/image.gif is 1000 by 1000 pixels, theproxy server may resize the image to 100 by 100 pixels. Resizing theimage typically includes compressing the image while maintaining theaspect ratio of the image. Flow then moves to operation 1030 where theproxy server transmits a response to the requesting client device withthe resized image. Flow then moves to operation 1035, where the proxyserver stores the resized image in its cache.

Thus, based on how the image is set to be displayed and the size of theviewport, an appropriately sized image will be received and displayed.This saves bandwidth in downloading files that are larger than what willbe displayed and reduces the page loading time. This also helps withvisitors with limited data plans not saturate their data plan caps(e.g., mobile users). In addition, this may be done without the customerhaving to change a single line of their HTML code.

Although FIG. 10 illustrates a particular order of operations, it shouldbe understood that such order is exemplary (e.g., alternativeembodiments may perform the operations in a different order, combinecertain operations, overlap certain operations, etc.). By way of aspecific example, FIG. 10 may be augmented by the following. Afterreceiving a request for the image and there is not a version of theimage in cache with the requested dimensions or within a predefinedrange of the requested dimensions, the image may be transmitted to therequesting client device without it being resized. The resizing of theimage and storing of the resized image occur as a separate process inthe background. This alternative embodiment has the benefit of returningthe image quickly to the first visitor (at least the first visitorrequesting those specific dimensions of the image) and resizing theimage for future visitors that request the image have similardimensions.

Configuring Deferred Image Loading and/or Image Resizing

In one embodiment, customers of the service (e.g., domain owners and/orpersonnel working on behalf of domain owners) configure their domain orportion of their domain (e.g., particular page(s) of their domain) fordeferred image loading and/or image resizing, without modifying a singleline of HTML code. For example, the control servers 125 may provide aninterface for the customers to configure the image loading settings fortheir site (whether deferred image loading and/or image resizing areenabled).

FIG. 11 is an exemplary interface 1110 for the control servers 125 thatallows a customer to enable or disable the deferred image loading and/orimage auto-resizing functionality described herein, according to oneembodiment. In one embodiment, the interface 1110 is available over theInternet as a website. However, in other embodiments, the functionalityof the interface 1110 may be provided through a mobile applicationinterface. The toggle button 1115 allows the customer to enable ordisable auto-resizing of images. The toggle button 1120 allows thecustomer to enable or disable deferred loading of images. Upon making achange to the image loading settings, the control servers 125 update theproxy servers 120 with the updated image loading settings. For example,upon enabling the deferred image loading, the proxy server(s) 120 thatreceive requests for the customer's pages will insert the set ofclient-side script(s) and/or references to the set of client-sidescript(s) that provide the functionality of the deferred image loading.Upon enabling the image auto-resizing, the proxy server(s) 120 thatreceive requests for the customer's pages will insert the set ofclient-side script(s) and/or references to the set of client-sidescript(s) that provide the functionality of the image auto-resizing.

As illustrated in FIG. 12, the computer system 1200, which is a form ofa data processing system, includes the bus(es) 1250 which is coupledwith the processing system 1220, power supply 1225, memory 1230, and thenonvolatile memory 1240 (e.g., a hard drive, flash memory, Phase-ChangeMemory (PCM), etc.). The bus(es) 1250 may be connected to each otherthrough various bridges, controllers, and/or adapters as is well knownin the art. The processing system 1220 may retrieve instruction(s) fromthe memory 1230 and/or the nonvolatile memory 1240, and execute theinstructions to perform operations described herein. The bus 1250interconnects the above components together and also interconnects thosecomponents to the display controller & display device 1270, Input/Outputdevices 1280 (e.g., NIC (Network Interface Card), a cursor control(e.g., mouse, touchscreen, touchpad, etc.), a keyboard, etc.), and theoptional wireless transceiver(s) 1290 (e.g., Bluetooth, WiFi, Infrared,etc.). In one embodiment, the client devices 110A-I, the controlserver(s) 125, the proxy server(s) 120, and/or the origin servers 130A-Ncan take the form of the computer system 1200.

The techniques shown in the figures can be implemented using code anddata stored and executed on one or more computing devices (e.g., clientdevices, servers, etc.). Such computing devices store and communicate(internally and/or with other computing devices over a network) code anddata using machine-readable media, such as machine-readable storagemedia (e.g., magnetic disks; optical disks; random access memory; readonly memory; flash memory devices; phase-change memory) andmachine-readable communication media (e.g., electrical, optical,acoustical or other form of propagated signals—such as carrier waves,infrared signals, digital signals, etc.). In addition, such computingdevices typically include a set of one or more processors coupled to oneor more other components, such as one or more storage devices, userinput/output devices (e.g., a keyboard, a touchscreen, and/or adisplay), and network connections. The coupling of the set of processorsand other components is typically through one or more busses and bridges(also termed as bus controllers). The storage device and signalscarrying the network traffic respectively represent one or moremachine-readable storage media and machine-readable communication media.Thus, the storage device of a given computing device typically storescode and/or data for execution on the set of one or more processors ofthat computing device. Of course, one or more parts of an embodiment ofthe invention may be implemented using different combinations ofsoftware, firmware, and/or hardware.

While the flow diagrams in the figures show a particular order ofoperations performed by certain embodiments of the invention, it shouldbe understood that such order is exemplary (e.g., alternativeembodiments may perform the operations in a different order, combinecertain operations, overlap certain operations, etc.).

While the invention has been described in terms of several embodiments,those skilled in the art will recognize that the invention is notlimited to the embodiments described, can be practiced with modificationand alteration within the spirit and scope of the appended claims. Thedescription is thus to be regarded as illustrative instead of limiting.

1. A method in a client device, the method comprising: receiving a webpage, wherein the web page includes at least one reference to an image,and wherein the web page includes a set of one or more client-sidescripts or one or more references to one or more client side scriptsthat, when executed by the client device, perform the following:determining a display size of the image; determining that an imageplaceholder corresponding to the image is in a viewport of a clientnetwork application of the client device or within a defined distancefrom the viewport; and responsive to the determination that the imageplaceholder corresponding to the image is within the viewport of theclient network application of the client device or within a defineddistance from the viewport, causing the client device to transmit arequest for the image, the request including an indication of a set ofone or more requested dimensions for the image that is equal orsubstantially equal to the determined display size; receiving the image,the image having a size that is equal or substantially equal to the setof requested dimensions; and displaying the image.
 2. The method ofclaim 1, further comprising: determining a set of presented dimensionsfor the image, the set of presented dimensions indicating how the imageis configured to be displayed.
 3. The method of claim 2, whereindetermining the set of presented dimensions for the image includesperforming one or more of: analyzing the reference to the image todetermine whether it has a width or height variable set; and examining aCascaded Style Sheet (CSS) style to determine whether it governs thedisplay size of the image.
 4. The method of claim 2, wherein determiningthe display size of the image includes performing the following:determining a size of a viewport of a client network application of theclient device; determining a set of presented dimensions for the image,the set of presented dimensions indicating how the image is configuredto be displayed; determining that the set of presented dimensions forthe image exceeds the size of the viewport; and setting the display sizeof the image to not exceed the size of the viewport, wherein therequested set of dimensions does not exceed the size of the viewport. 5.The method of claim 2, wherein determining the display size of the imageincludes performing the following: determining a size of a viewport of aclient network application of the client device; determining a set ofpresented dimensions for the image, the set of presented dimensionsindicating how the image is configured to be displayed; determining thatthe set of presented dimensions for the image is smaller than the sizeof the viewport; and setting the display size of the image to be equalor substantially equal to the set of presented dimensions, wherein therequested set of dimensions is equal or substantially equal to the setof presented dimensions.
 6. The method of claim 2, wherein determiningthe display size of the image includes performing the following:determining a set of presented dimensions for the image, the set ofpresented dimensions indicating how the image is configured to bedisplayed; setting the display size of the image to be equal orsubstantially equal to the set of presented dimensions, wherein therequested set of dimensions is equal or substantially equal to the setof presented dimensions.
 7. (canceled)
 8. A method for automaticallyresizing one or more images of a web page, the method comprising:receiving a request for the web page, wherein the request originatesfrom a client network application of a client device; retrieving therequested web page, wherein the web page includes a reference to animage; modifying code of the retrieved web page such that when theclient network application issues a request for the image, that requestwill include an indication of a set of one or more requested dimensionsfor the image; and transmitting the modified web page to the clientdevice.
 9. The method of claim 8, wherein modifying the code of theretrieved web page includes modifying the reference to the image suchthat the client network application will not request that image untilafter the set of requested dimensions is determined.
 10. The method ofclaim 9, wherein modifying the code of the retrieved web page includesadding one or more client-side scripts or one or more references to oneor more client-side scripts that, when executed by the client networkapplication, determine the set of requested dimensions for the image.11. The method of claim 10, wherein the one or more client-side scriptsor references to one or more client-side scripts that are added to thecode of the retrieved web page perform the following operations whenexecuted by the client network application: determine a size of aviewport of the client network application; determine a set of presenteddimensions for the image, the set of presented dimensions indicating howthe image is configured to be displayed by the client networkapplication; determine that the set of presented dimensions for theimage exceeds the size of the viewport; and cause the request for theimage to be issued, wherein the set of requested dimensions does notexceed the size of the viewport.
 12. The method of claim 10, wherein theone or more client-side scripts or references to one or more client-sidescripts that are added to the code of the retrieved web page perform thefollowing operations when executed by the client network application:determine a size of a viewport of the client network application;determine a set of presented dimensions for the image, the set ofpresented dimensions indicating how the image is configured to bedisplayed by the client network application; determine that the set ofpresented dimensions for the image is smaller than the size of theviewport; and cause the request for the image to be issued where the setof requested dimensions is equal or substantially equal to the set ofpresented dimensions.
 13. The method of claim 10, wherein the one ormore client-side scripts or references to one or more client-sidescripts that are added to the code of the retrieved web page perform thefollowing operations when executed by the client network application:determine a set of presented dimensions for the image, the set ofpresented dimensions indicating how the image is configured to bedisplayed by the client network application; and cause the request forthe image to be issued where the set of requested dimensions is equal orsubstantially equal to the set of presented dimensions.
 14. The methodof claim 8, further comprising: receiving a request for the image thatoriginates from the client network application, wherein the request forthe image includes an indication of a set of one or more requesteddimensions for the image; retrieving the image; resizing the image basedon the set of requested dimensions for the image; and transmitting theresized image to the client network application.
 15. The method of claim8, further comprising: receiving a request for the image that originatesfrom the client network application, wherein the request for the imageincludes an indication of a set of one or more requested dimensions forthe image; retrieving a version of the requested image that has beenresized based on the set of requested dimensions for the image; andtransmitting the resized version of the requested image to the clientnetwork application.
 16. A non-transitory machine-readable storagemedium that provides instructions that, when executed by a processor ofa client device, cause the processor to perform operations comprising:receiving a web page, wherein the web page includes at least onereference to an image, and wherein the web page includes a set of one ormore client-side scripts or one or more references to one or more clientside scripts that, when executed by the client device, perform thefollowing: determining a display size of the image; determining that animage placeholder corresponding to the image is in a viewport of aclient network application of the client device or within a defineddistance from the viewport; and responsive to the determination that theimage placeholder corresponding to the image is within the viewport ofthe client network application of the client device or within a defineddistance from the viewport, causing the client device to transmit arequest for the image, the request including an indication of a set ofone or more requested dimensions for the image that is equal orsubstantially equal to the determined display size; receiving the image,the image having a size that is equal or substantially equal to the setof requested dimensions; and displaying the image.
 17. Thenon-transitory machine-readable storage medium of claim 16, wherein themedium further provides instructions that, when executed by theprocessor, perform the following operation: determining a set ofpresented dimensions for the image, the set of presented dimensionsindicating how the image is configured to be displayed.
 18. Thenon-transitory machine-readable storage medium of claim 17, whereindetermining the set of presented dimensions for the image includesperforming one or more of: analyzing the reference to the image todetermine whether it has a width or height variable set; and examining aCascaded Style Sheet (CSS) style to determine whether it governs thedisplay size of the image.
 19. The non-transitory machine-readablestorage medium of claim 17, wherein determining the display size of theimage includes performing the following: determining a size of aviewport of a client network application of the client device;determining a set of presented dimensions for the image, the set ofpresented dimensions indicating how the image is configured to bedisplayed; determining that the set of presented dimensions for theimage exceeds the size of the viewport; and setting the display size ofthe image to not exceed the size of the viewport, wherein the requestedset of dimensions does not exceed the size of the viewport.
 20. Thenon-transitory machine-readable storage medium of claim 17, whereindetermining the display size of the image includes performing thefollowing: determining a size of a viewport of a client networkapplication of the client device; determining a set of presenteddimensions for the image, the set of presented dimensions indicating howthe image is configured to be displayed; determining that the set ofpresented dimensions for the image is smaller than the size of theviewport; and setting the display size of the image to be equal orsubstantially equal to the set of presented dimensions, wherein therequested set of dimensions is equal or substantially equal to the setof presented dimensions.
 21. The non-transitory machine-readable storagemedium of claim 17, wherein determining the display size of the imageincludes performing the following: determining a set of presenteddimensions for the image, the set of presented dimensions indicating howthe image is configured to be displayed; setting the display size of theimage to be equal or substantially equal to the set of presenteddimensions, wherein the requested set of dimensions is equal orsubstantially equal to the set of presented dimensions.
 22. (canceled)23. A non-transitory machine-readable storage medium that providesinstructions that, when executed by a processor, cause the processor toperform operations comprising: receiving a request for a web page,wherein the request originates from a client network application of aclient device; retrieving the requested web page, wherein the web pageincludes a reference to an image; modifying code of the retrieved webpage such that when the client network application issues a request forthe image, that request will include an indication of a set of one ormore requested dimensions for the image; and transmitting the modifiedweb page to the client device.
 24. The non-transitory machine-readablestorage medium of claim 23, wherein modifying the code of the retrievedweb page includes modifying the reference to the image such that theclient network application will not request that image until after theset of requested dimensions is determined.
 25. The non-transitorymachine-readable storage medium of claim 24, wherein modifying the codeof the retrieved web page includes adding one or more client-sidescripts or one or more references to one or more client-side scriptsthat, when executed by the client network application, determine the setof requested dimensions for the image.
 26. The non-transitorymachine-readable storage medium of claim 25, wherein the one or moreclient-side scripts or references to one or more client-side scriptsthat are added to the code of the retrieved web page perform thefollowing operations when executed by the client network application:determine a size of a viewport of the client network application;determine a set of presented dimensions for the image, the set ofpresented dimensions indicating how the image is configured to bedisplayed by the client network application; determine that the set ofpresented dimensions for the image exceeds the size of the viewport; andcause the request for the image to be issued, wherein the set ofrequested dimensions does not exceed the size of the viewport.
 27. Thenon-transitory machine-readable storage medium of claim 25, wherein theone or more client-side scripts or references to one or more client-sidescripts that are added to the code of the retrieved web page perform thefollowing operations when executed by the client network application:determine a size of a viewport of the client network application;determine a set of presented dimensions for the image, the set ofpresented dimensions indicating how the image is configured to bedisplayed by the client network application; determine that the set ofpresented dimensions for the image is smaller than the size of theviewport; and cause the request for the image to be issued where the setof requested dimensions is equal or substantially equal to the set ofpresented dimensions.
 28. The non-transitory machine-readable storagemedium of claim 25, wherein the one or more client-side scripts orreferences to one or more client-side scripts that are added to the codeof the retrieved web page perform the following operations when executedby the client network application: determine a set of presenteddimensions for the image, the set of presented dimensions indicating howthe image is configured to be displayed by the client networkapplication; and cause the request for the image to be issued where theset of requested dimensions is equal or substantially equal to the setof presented dimensions.
 29. The non-transitory machine-readable storagemedium of claim 23, wherein the medium further provides instructionsthat, when executed by the processor, cause the processor to perform thefollowing operations: receiving a request for the image that originatesfrom the client network application, wherein the request for the imageincludes an indication of a set of one or more requested dimensions forthe image; retrieving the image; resizing the image based on the set ofrequested dimensions for the image; and transmitting the resized imageto the client network application.
 30. The non-transitorymachine-readable storage medium of claim 23, wherein the medium furtherprovides instructions that, when executed by the processor, cause theprocessor to perform the following operations: receiving a request forthe image that originates from the client network application, whereinthe request for the image includes an indication of a set of one or morerequested dimensions for the image; retrieving a version of therequested image that has been resized based on the set of requesteddimensions for the image; and transmitting the resized version of therequested image to the client network application.